package org.aiforum.frountend.common;

import org.aiforum.domain.User;

/**
 * 用户帮助类
 * @author JAVA
 *
 */
public class UserHelper {
	
	/**
	 * 判断是否登录
	 * @return
	 */
	public static boolean hasLogin(String token){
		return null != CacheContext.getCache(token, User.class);
	}
	
	/**
	 * 获取当前登录用户账号
	 * @return
	 */
	public static String getCurrentAccount(String token){
		User user = CacheContext.getCache(token, User.class);
		if(null != user){
			return user.getAccount();
		}
		return null;
	}
	
	/**
	 * 获取当前登录用户ID
	 * @return
	 */
	public static int getCurrentUserId(String token){
		User user = CacheContext.getCache(token, User.class);
		if(null != user){
			return user.getUserId();
		}
		return 0;
	}

}
